package cn.iocoder.yudao.module.system.dal.mysql.goal;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.goal.StudentMajorGroupGoalDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

/**
 * 学生目标专业组 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface StudentMajorGroupGoalMapper extends BaseMapperX<StudentMajorGroupGoalDO> {

    default StudentMajorGroupGoalDO selectByUserIdAndRecruitCodeAndMajorGroup(Long userId, String recruitCode, String majorGroup, Integer year) {
        return selectOne(new LambdaQueryWrapperX<StudentMajorGroupGoalDO>()
                .eq(StudentMajorGroupGoalDO::getUserId, userId)
                .eq(StudentMajorGroupGoalDO::getRecruitCode, recruitCode)
                .eq(StudentMajorGroupGoalDO::getUniversityMajorGroup, majorGroup)
                .eqIfPresent(StudentMajorGroupGoalDO::getYear, year));
    }

    default List<StudentMajorGroupGoalDO> selectListByUserId(Long userId) {
        return selectList(new LambdaQueryWrapperX<StudentMajorGroupGoalDO>()
                .eq(StudentMajorGroupGoalDO::getUserId, userId)
                .orderByAsc(StudentMajorGroupGoalDO::getSort)
                .orderByDesc(StudentMajorGroupGoalDO::getCreateTime));
    }

    default List<StudentMajorGroupGoalDO> selectListByUserIds(Collection<Long> userIds) {
        return selectList(new LambdaQueryWrapperX<StudentMajorGroupGoalDO>()
                .in(StudentMajorGroupGoalDO::getUserId, userIds));
    }
}
